package com.qjdchina.sku.biz.impl;

import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qjdchina.commons.enums.IsDeleted;
import com.qjdchina.commons.result.Result;
import com.qjdchina.sku.biz.CompanyBrandManager;
import com.qjdchina.sku.dao.mapper.CompanyBrandMapper;
import com.qjdchina.sku.model.CompanyBrand;
import com.qjdchina.sku.service.enums.SkuResultCode;

/**
 * 用戶品牌关联
 * @author shenpingfeng
 * 2017年1月12日
 */
@Service
public class CompanyBrandManagerImpl implements CompanyBrandManager {

    public static final Logger LOGGER = LoggerFactory.getLogger(CompanyBrandManagerImpl.class);

    @Autowired
    private CompanyBrandMapper companyBrandMapper ;

    /**
	 * 创建用户品牌关联
	 * shenpingfeng
	 * 2017年1月12日
	 * @param userBrand
	 * @return
	 */
    @Override
    public Result<String> create(CompanyBrand companyBrand) {
    	if(companyBrand == null){
    		return new Result<String>(SkuResultCode.PARAMETER_NOT_EMPTY);
    	}
    	companyBrand.setIsDeleted(IsDeleted.NO.getValue());
    	companyBrand.setGmtModified(new Date());
    	companyBrand.setGmtCreated(new Date());
    	int row = companyBrandMapper.insertSelective(companyBrand);
    	if(row == 0){
    		return new Result<String>(SkuResultCode.ADD_FAIL);
    	}
    	return new Result<String>(SkuResultCode.SUCCESS,"");
     
    }

   
}
